export default {
	namespaced: true,
	
	//状态
	state: () => ({
		//邮箱内容数组，用于储存聊天的用户与信息数据
		//元素为对象：{图片img,用户名name,新信息数newNum,最近消息msg,最近消息时间time}
		MailBox : JSON.parse(uni.getStorageSync('mail') || '[]'),
	}),
	
	//方法
	mutations: {
		//将得到的信息内容储存在此处
		StoreMailBox(state,mailBox){
			state.MailBox = mailBox;
			this.commit('m_mail/saveToStorage');
		},
		//置顶信息单元
		UpMessageUnit(state,index){
			var temp = state.MailBox[0];
			state.MailBox[0] = state.MailBox[index];
			state.MailBox[index] = temp;
			this.commit('m_mail/saveToStorage');
		},
		//删除信息单元
		DeleteMessageUnit(state,index){
			state.MailBox.splice(index,1);
			this.commit('m_mail/saveToStorage');
		},
		//保存至JSON中
		saveToStorage(state){
			uni.setStorageSync('mail',JSON.stringify(state.MailBox));
			//console.log(JSON.parse(uni.getStorageSync('mail')));
		},
	},
	
	//通过运算后的数据
	getters: {
		
	},
}